import request from '@/utils/request'

// 查询采购订单列表
export function listPurchaseOrders(query) {
  return request({
    url: '/ck/purchase/findAll_po/',
    method: 'post',
    params: query
  })
}

// 查询采购订单详情
export function listPurchaseOrderDetails(query) {
  return request({
    url: '/ck/purchase/findAll_po_line/',
    method: 'post',
    params: query
  })
}

// 新增/修改采购订单
export function savePurchaseOrder(data) {
  return request({
    url: '/ck/purchase/save_po/',
    method: 'post',
    data: data
  })
}

// 删除采购订单
export function deletePurchaseOrder(po_id) {
  return request({
    url: '/ck/purchase/delete_po/'+po_id,
    method: 'post'
  })
}

// 批量删除采购订单
export function batchDeletePurchaseOrders(poIds) {
  return request({
    url: '/ck/purchase/batch_delete_po/',
    method: 'post',
    data: poIds  // 直接传递ID数组，不再包装在对象中
  })
}

// 提交采购订单（更改状态为采购中）
export function submitPurchaseOrder(po_id) {
  return request({
    url: '/ck/purchase/updateStatus/'+po_id,
    method: 'post'
  })
}

// 更新采购订单状态
export function updatePurchaseOrderStatus(data) {
  return request({
    url: '/ck/purchase/update_status/',
    method: 'post',
    data: data
  })
} 

// 查询物料商品列表
export function listMaterialGoods(query) {
  return request({
    url: '/ck/purchase/findAll_wlgl/',
    method: 'post',
    data: query
  })
} 

// 查询产品商品列表
export function listProductGoods(query) {
  return request({
    url: '/ck/purchase/findAll_pro/',
    method: 'post',
    data: query  
  })
} 

// 查询生产采购商品列表
export function listPurchaseGoods(query) {
  return request({
    url: '/ck/purchase/findPurchase/',
    method: 'post',
    params: query  
  })
} 

// 查询供应商列表
export function listSupplier(query) {
  return request({
    url: '/ck/purchase/findSupplier/',
    method: 'post',
    data: query  
  })
} 

// 添加采购订单
export function addPurchaseOrder(order,listOrderLine) {
  return request({
    url: '/ck/purchase/addPurchaseOrder/',
    method: 'post',
    data: {order,listOrderLine}  
  })
} 

// 根据采购订单ID查询采购订单行信息
export function selectOrderLine_id(po_id) {
  return request({
    url: '/ck/purchase/selectOrderLine_id/'+po_id,
    method: 'get'
  })
} 

// 到货入库
export function arrivalStorage(arrDto,update_by) {
  return request({
    url: '/ck/purchase/arrivalStorage/',
    method: 'post',
    data: {arrDto,update_by}  
  })
} 

